//
//  YFLalbumCollectionViewCell.m
//  Music
//
//  Created by dllo on 16/6/12.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "YFLalbumCollectionViewCell.h"
#import "YFLlittleAlbumCollectionViewCell.h"
@implementation YFLalbumCollectionViewCell
-(instancetype)initWithFrame:(CGRect)frame

{
    
    self = [super initWithFrame:frame];
    if (self) {
        self.dataArray = [NSMutableArray array];
        
        UICollectionViewFlowLayout *littleFlowLayout =[[UICollectionViewFlowLayout alloc]init];
        littleFlowLayout.itemSize = CGSizeMake((Screenwidth-45)/2, 150);
        littleFlowLayout.sectionInset = UIEdgeInsetsMake(10, 15, 10, 10);
        littleFlowLayout.minimumLineSpacing = 10;
        littleFlowLayout.minimumInteritemSpacing = 10;
        
        self.littleCollectionView =[[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, Screenwidth, Screenheight-64-49-(Screenheight/2-64)-5)collectionViewLayout:littleFlowLayout];
        self.littleCollectionView.delegate = self;
        self.littleCollectionView.dataSource = self;
        
        self.littleCollectionView.backgroundColor =[UIColor whiteColor];
        
        
        [self.contentView addSubview:self.littleCollectionView];
        [self.littleCollectionView registerClass:[YFLlittleAlbumCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
        
        
    }
    return self;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.dataArray.count;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    YFLlittleAlbumCollectionViewCell *cell =[self.littleCollectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    YFLalbumModel *model =[self.dataArray objectAtIndex:indexPath.item];
    cell.ALBUMmodel = model;
    cell.backgroundColor = [UIColor purpleColor];
    return cell;
}



-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"%@",indexPath);
 
    
    
    
    
}









-(void)setDataArray:(NSMutableArray *)dataArray
{
    if (_dataArray != dataArray) {
        _dataArray = dataArray;
        [self.littleCollectionView reloadData];
    }
}
@end
